<?php

require dirname(__FILE__) . '/../libs/medoo1.2.php';

class PDODatabase
{
    private $config;
    private $link;

    public function __construct()
    {
        $this->config = require dirname(__FILE__) . '/../forum_support/config/config.php';
    }

    /**
     * 链接数据库
     * @return medoo|string
     */
    function connect()
    {
        try {
            $this->link = new medoo($this->config);
            return $this->link;
        } catch (Exception $e) {
            return $e->getMessage();
        }
    }

    /**
     * 释放资源，pdo中直接关闭连接
     * @param $res
     */
    function free_result($res)
    {
        $this->link = null;
    }
}

//$pdo = new pdo_database();
//$db = $pdo->connect();
//echo json_encode($result);
//exit();